<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form label-width="80px">
        <el-form-item label="名字" style="width: 200px" class="filter-item">
          <el-input />
        </el-form-item>
        <el-button v-waves style="margin-left: 20px" class="filter-item" type="primary" icon="el-icon-search">
          查询
        </el-button>
      </el-form>

    </div>
    <span>题库列表</span>
    <el-table  :data="list" border fit highlight-current-row style="width: 100%">
      <el-table-column align="center" label="题库名" >
        <template slot-scope="{row}">
          <span>{{ row.id }}</span>
        </template>
      </el-table-column>

      <el-table-column width="180px"  label="试题数量">
        <template slot-scope="{row}">
          <span>{{ row.num }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="150">
        <template >
          <el-link type="primary" href="../#/table/inline-edit-table-detail">
            详情
          </el-link>
          <el-link type="primary" style="margin-left: 20px">
            修改
          </el-link>
          <el-link style="margin-left: 20px" type="primary">
            删除
          </el-link>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      title="添加题库"
      :visible.sync="centerDialogVisible"
      width="30%"
      >
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="题库名称">
          <el-input ></el-input>
        </el-form-item>
        <el-button type="primary" >选择试题</el-button>
      </el-form>
    <el-button style="margin-top: 20px" type="primary" @click="centerDialogVisible = false">确 定</el-button>
    </el-dialog>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'

export default {
  name: 'InlineEditTable',
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'info',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
        centerDialogVisible: false,
      list: [
        {
          id: '题库1',
          num: '100'
        },
        {
          id: '题库2',
          num: '100'
        },
        {
          id: '题库3',
          num: '100'
        }
      ],
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10
      }
    }
  },
  methods: {

    cancelEdit(row) {
      row.title = row.originalTitle
      row.edit = false
      this.$message({
        message: 'The title has been restored to the original value',
        type: 'warning'
      })
    },
    confirmEdit(row) {
      row.edit = false
      row.originalTitle = row.title
      this.$message({
        message: 'The title has been edited',
        type: 'success'
      })
    }
  }
}
</script>

<style scoped>
.edit-input {
  padding-right: 100px;
}
.cancel-btn {
  position: absolute;
  right: 15px;
  top: 10px;
}
</style>
